import Rd from "../qbasics/basics/Phere";
import Block from "../qbasics/basics/Block";
/**
 * 字典
 */
export default class Dict{
    constructor() {
        this.phere=new Rd();
        this.phere.addBlock(new Block())
        this.phere.addBlock(new Block())
        this.phere.addBlock(new Block())
        this.WORD_INDEX=1;
    }


    /**
     * 导出数据
     * @returns {Uint8Array}
     */
    outData(){
        return this.phere.outData();
    }

    /**
     * 加载数据
     * @param dataBuff
     */
    lodaData(dataBuff){
        this.phere.loadData(dataBuff)
    }



    /**
     * 添加属性
     */
    addArr(id,row){

      return    this.phere.addRow(id,row);
    }

    /**
     * 添加搜索 意
     * @param row
     * @param block
     */
    addIdea(row,block){
        //先只做简单搜索
/*        if(row){
          if(block){

          }else {

          }
        }*/

        let rowId =this.phere.searchRow(this.WORD_INDEX,row);
        if(!rowId){

              rowId =  this.phere.addBlock(block)
             row.save(4,rowId)
            rowId =   this.phere.addRow(this.WORD_INDEX,row);
        }
        return rowId;

    }
    /**
     *  查找搜索 意
     * @param row
     * @param block
     */
    searchIdea(row,block){
        //先只做简单搜索
        /*        if(row){
                  if(block){

                  }else {

                  }
                }*/

        let rowId =this.phere.searchRow(this.WORD_INDEX,row);
        return rowId;

    }
    /**
     *  获取 意
     * @param row
     * @param block
     */
    findIdea(id){
        //先只做简单搜索
        /*        if(row){
                  if(block){

                  }else {

                  }
                }*/


        return  this.phere.find(id);

    }
}
